@extends('default.layouts.personalPublic')
@section('title', '新增搜索器')
@section('headcss')
    @parent
    <link rel="stylesheet" href="{{asset('/default/css/personal/resumeBasic.css')}}">
@endsection
@section('rightcon')
    <div class="right">
        <!--搜索器-->
        <div class="jright">
            <div class="content">
                <div class="jobtitle">
                    <div class="tithead">
                        <h2>新增搜索器</h2>
                    </div>
                </div>
            </div>
        </div>
        {{--职位搜索条件--}}
        <div class="rightMain">
            {{--简历错误信息--}}
            @if(count($errors)>0)
                <div class="errors">
                    <ul>
                        @if(is_object($errors))
                            @foreach($errors->all() as $error)
                                <li><span>{{$error}}</span></li>
                            @endforeach
                        @else
                            <li><span>{{$error}}</span></li>
                        @endif
                    </ul>
                </div>
            @endif
            <div class="basicInformation"><span style=" font-size: 15px;">职位搜索条件</span></div>
            <div class="jobInfo searchInfo">
                <form action="{{url("personal/search")}}" method="post" name="searchForm" id="searchForm">
                    {{csrf_field()}}
                    {{--职位搜索条件--}}
                    <dl>
                        <dt><span class="caption">工作地区</span></dt>
                        <input name="jobarea1" type="hidden" id="jobarea1" value="">
                        <input name="jobarea2" type="hidden" id="jobarea2" value="">
                        <input name="jobarea3" type="hidden" id="jobarea3" value="">
                        <input name="jobarea4" type="hidden" id="jobarea4" value="">
                        <input name="jobarea5" type="hidden" id="jobarea5" value="">
                        <dd>
                            <span class="jList"  id="workplaceInput">
                                <input type="text" name="workplace" id="workplace" value="{{old('workplace')}}" readonly
                                       style="cursor: text"
                                       placeholder="请选择工作地区"/>
                                <i></i>
                            </span>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">工作岗位</span></dt>
                        <input name="jobsort1" type="hidden" id="jobsort1" value="">
                        <input name="jobsort2" type="hidden" id="jobsort2" value="">
                        <input name="jobsort3" type="hidden" id="jobsort3" value="">
                        <input name="jobsort4" type="hidden" id="jobsort4" value="">
                        <input name="jobsort5" type="hidden" id="jobsort5" value="">
                        <dd>
                            <span class="jList" id="posCateInput">
                                <input type="text" name="jobsort" id="jobsort" value="" readonly style="cursor: text"
                                       placeholder="请选择工作岗位"/>
                                <i></i>
                            </span>
                        </dd>
                    </dl>

                    <dl>
                        <dt><span class="caption">行业类别</span></dt>
                        <input name="industry1" type="hidden" id="industry1" value="">
                        <input name="industry2" type="hidden" id="industry2" value="">
                        <input name="industry3" type="hidden" id="industry3" value="">
                        <input name="industry4" type="hidden" id="industry4" value="">
                        <input name="industry5" type="hidden" id="industry5" value="">
                        <dd>
                            <span class="jList" id="callInput">
                                <input type="text" name="industry" id="industry" value="" readonly style="cursor: text"
                                       placeholder="请选择行业类别"/>
                                <i></i>
                            </span>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">性别要求</span></dt>
                        <dd>
                            <span>
                                <input type="radio" name="sex" id="sex1" class="radios" value="1"/>
                                <label for="sex1">男</label>
                            </span>
                             <span class="mLeftTen">
                                <input type="radio" name="sex" id="sex2" class="radios" value="2"/>
                                <label for="sex2">女</label>
                            </span>
                            <span class="mLeftTen">
                                <input type="radio" name="sex" id="sex3" checked class="radios" value="0"/>
                                <label for="sex3">不限</label>
                            </span>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">学历要求</span></dt>
                        <dd>
                            <input id="education" name="education" type="hidden">
                            <div id="education_select" class="select"><span><a></a></span><i></i></div>
                        </dd>
                    </dl>

                    <dl>
                        <dt><span class="caption">年龄要求</span></dt>
                        <dd>
                            <input id="age" name="age" type="hidden">
                            <div id="age_select" class="select"><span><a></a></span><i></i></div>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">工作经验</span></dt>
                        <dd>
                            <input id="work_year" name="work_year" type="hidden" value="">
                            <div id="work_year_select" class="select" style="width: 180px;"><span><a></a></span><i></i>
                            </div>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">关键字</span></dt>
                        <dd><input type="text" name="keyword" id="keyword" value="" style="width: 350px;"
                                   placeholder="请输入关键字" tip="请输入关键字"/></dd>
                        <dd>
                            <input id="keyword_type" name="keyword_type" type="hidden">
                            <div id="keyword_type_select" class="select"><span><a></a></span><i></i></div>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">发布日期</span></dt>
                        <dd>
                            <input id="release_date" name="release_date" type="hidden">
                            <div id="release_date_select" class="select"><span><a></a></span><i></i></div>
                        </dd>
                    </dl>
                    <dl>
                        <dt><span class="caption">搜索器名</span><span class="asterisk">*</span></dt>
                        <dd><input type="text" name="search_name" id="search_name" value="" style="width: 350px;"
                                   placeholder="请输入搜索器名" tip="请输入搜索器名"/></dd>
                        <dd class="errinfo"></dd>
                    </dl>
                    <dl style="margin-top:25px;">
                        <dt></dt>
                        <dd><input name="sub" class="subs btn" type="submit" value="保存搜索器"></dd>
                        <dd>
                            <input name="btn" class="subs btn cancel" type="button" value="返回" onclick="history.back()">
                        </dd>
                    </dl>
                </form>
            </div>
        </div>
    </div>
    @endsection
    @section('footerjs')
    @parent
    <!--select加载插件-->
    <script type="text/javascript" src="{{Resources::jsOption('jobsearch')}}"></script>
    {{--工作岗位--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.position.js')}}"></script>
    {{--工作地区--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.area.js')}}"></script>
    {{--单个地区--}}
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.calling.js')}}"></script>
    <script type="text/javascript" src="{{asset('/default/js/jquery/jquery.validate.extend.js')}}"></script>
    <script>
        $(function(){
            $('#search').addClass('on');

            var searchForm = $('.rightMain').find("#searchForm");
            searchForm.find("#workplaceInput").click(function(){
                workplaceInput('','type');
            });
            searchForm.find("#posCateInput").click(function(){
                posCateInput('');
            });
            searchForm.find("#callInput").click(function(){
                callInput('');
            });
            //年龄要求
            var age = [];
            for (var i = 18; i <= 60; i++) {
                age.push({"text": i, "value": i});
            }
            age.unshift({"value": '', "text": "不限"});
            $("#age").select({
                optionData: age
            });
            //搜索关键类型
            var keyword_type = [
                {"value": 1, "text": "全文"},
                {"value": 2, "text": "职位名称"},
                {"value": 3, "text": "公司名称"}
            ];
            $("#searchForm #keyword_type").select({
                optionData: keyword_type
            });
            //最高学历
            option_education.unshift({"value": '', "text": "不限"});
            $("#education").select({
                optionData: option_education
            });
            //工作经验
            option_work_year.unshift({"value": '', "text": "不限"});
            $("#work_year").select({
                optionData: option_work_year
            });
            //发布日期
            $("#release_date").select({
                selected:30,
                optionData: option_release_date
            });
        });
        //搜索器表单验证 使用jQuery Validate 插件进行验证
        $('#searchForm').validate({
            //指定使用什么标签标记错误。
            errorElement: "span",
            //一个函数，可以自定义错误放到哪里。
            errorPlacement: function(error, element) {
                $(element).parents('dl').find(".errinfo").append(error);
            },
            //自定义错误消息
            tipPlacement: function(element,tip) {
                $(element).parents('dl').find(".errinfo").append(tip);
            },
            //通过验证后执行的函数
            success: function(label){
                if(label.parents('dl').find('dd input').val()!=''){
                    label.text('ok!').addClass('success');
                }
            },
            //未验证后执行的函数
            highlight: function(element, errorClass) {
                $( element ).closest( "dl" ).find("dd.errinfo").find('span').removeClass('success');
            },
            ignore:"",
            //js上面添加验证规则
            rules: {
                search_name: {
                    required: true
                }
            },
            //错误信息提示修改
            messages: {
                search_name: {
                    required: "请输入搜索器名"
                }
            },
            submitHandler:function(form) {
                form.submit();
            }
        });
    </script>

@endsection